/**
 *	\file AKTTTImageProvider.m
 *  
 *  \section desc_sec Description
 *  Description
 *  
 *  \if copyright
 *  	Copyright 2008 Ben Chen. All rights reserved.
 *  \endif
 *  
 *  \section hist_sec Change History:
 *  	-	1/18/08		BC		Created this file
 *  
 *  <hr>
 *  \addtogroup AnimalKingdom
 *  @{
 */

#import "AKTTT.h"
#import "AKTTTImageProvider.h"

@implementation AKTTTImageProvider

// Return a autoreleased CGImageRef
- (CGImageRef)imageRefWithName:(NSString*)fileName type:(NSString*)type
{
	CGImageRef retVal;
	
	CGImageSourceRef source;
	source = CGImageSourceCreateWithURL((CFURLRef)[NSURL fileURLWithPath:
												   [[NSBundle mainBundle] pathForResource:fileName ofType:type]], NULL);
	retVal = CGImageSourceCreateImageAtIndex(source, 0, NULL);
	CFRelease(source);
	
	[(id)retVal autorelease];
	return retVal;
}	

- (CGImageRef)imageForPiece:(AKPiece)piece
{
	CGImageRef retVal = NULL;
	
	if (piece.side == AKTTTBlack)
		retVal = [self imageRefWithName:@"AKTTTBlack" type:@"png"];
	else
		retVal = [self imageRefWithName:@"AKTTTWhite" type:@"png"];
	
	return retVal;
}

- (CGImageRef)backgroundImage
{
	return [self imageRefWithName:@"AKTTTBackground" type:@"png"];
}

- (CGImageRef)reflectionForPiece:(AKPiece)piece
{
	return [self imageRefWithName:@"AKTTTReflection" type:@"png"];
}

@end

/** @} */